package com.project.common.mvc;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ysy
 * @blame ysy
 * @date 2022-12-02
 */
@Configuration
public class PageWebMvcConfigurer implements WebMvcConfigurer {
    @Resource
    private ImplsPageableHandlerMethodArgumentResolver pageableHandlerMethodArgumentResolver;

    /**
     * 覆盖这个方法，把我们自定义的ImplsPageableHandlerMethodArgumentResolver加载到原始的mvc的resolvers里面去
     *
     * @param resolvers
     */
    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        resolvers.add(pageableHandlerMethodArgumentResolver);
    }

//    @Override
//    public void addFormatters(FormatterRegistry registry) {
//        registry.addConverterFactory(new IntegerCodeEnumConverterFactory());
//        registry.addConverterFactory(new StringCodeToEnumConverterFactory());
//    }
}
